from flask import Flask

# app = Flask(__name__)
# # 同时使用配置类和环境变量
# class Config(object):
#     REDIS = 'redis://127.0.0.1/1'
# app.config.from_object(Config)
# app.config.from_envvar('D03CONFIG')

class Config(object):
    REDIS = 'redis://127.0.0.1/1'
# 创建一个工厂函数,用于创建app对象
def create_app(config):
    """
    用于创建app对象
    :param config:
    :return:
    """
    app = Flask(__name__)
    app.config.from_object(config)
    # app.config.from_envvar('D03CONFIG')
    return app

app = create_app(Config)
print(app.config.get('REDIS'))
print(app.config.get('SECRET_KEY'))

@app.route('/')
def index():
    # raise ValueError("错误")
    return  'index'

# if __name__ == '__main__':
#     # host:绑定的ip端口
#     # port:监听的端口号
#     # debug:是否开启测试模式
#     app.run(host='127.0.0.1', port=5001, debug=True)